#pragma once

#include <vector>
#include <string>

/*
 * Functions to manage, read and write to processes and memory
 * Dependencies: bzbfile, bzbmem, bzbutil
 */


namespace bzbmem {


/*
 * Returns this process' PID
 */

int get_pid() noexcept;


/*
 * Returns the PIDs of the processes with the given name
 */

std::vector<int> get_pid_by_name(const std::string &name);


/*
 * Kills the specified process sending SIGTERM
 */
void kill(int pid);


/*
 * Stops execution for the specified amount of milliseconds
 */
void sleep(unsigned int millis);


/*
 * Reads the memory of the specified process starting from <address>
 */

std::vector<char> read(int pid, size_t address, size_t size);


/*
 * Writes the specified data to the specified process starting from <address>
 */

size_t write(int pid, size_t address, std::vector<char> &data, size_t size);


/*
 * Locks a memory block
 */

void lock(void *address, size_t size);


/*
 * Unlocks a memory block
 */

void unlock(void *address, size_t size);


#ifdef WINDOWS


/*
 * Returns the PID of the process with the specified window name
 * WARNING: This function is not supported on Linux
 */

int get_pid_by_win_name(const std::string& win_name);


/*
 * Injects a DLL into another process and returns the process' PID
 * WARNING: This function is only supported on Windows
 */

int inject_dll(int pid, std::string dllname);


/*
 * Injects code into another process
 * WARNING: This function is only supported on Windows
 */

int inject_code(int pid, void* code, size_t size, void* args);


#endif


/*
 * Checks whether a process is 64-bit or 32-bit
 */

bool is_64bit_proc(int pid);

}
